package com.dex4d.ui.dapp.adapter;

import android.app.Activity;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.dex4d.R;
import com.dex4d.ui.dapp.HistoryFragment;

import java.util.ArrayList;

/**
 * 作者    LiQingyi
 * 时间    2018/12/6 18:25
 * 文件    dex4d-android
 * 描述
 */
public class WebPagerAdapter extends FragmentPagerAdapter {


    private ArrayList<Fragment> fragments;
    private Activity activity;

    public WebPagerAdapter(Activity activity,FragmentManager fm) {
        super(fm);
        this.activity=activity;
        fragments = new ArrayList<>();
        fragments.add(HistoryFragment.newInstance("", 1));
        fragments.add(HistoryFragment.newInstance("", 0));
    }

    @Override
    public Fragment getItem(int i) {
        return fragments.get(i);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return position == 0 ? activity.getResources().getString(R.string.dapp_favorite) : activity.getResources().getString(R.string.dapp_history);
    }
}
